import Vue from 'vue';
import VueRouter from 'vue-router';
import routes from './routes.js';
import setTitle from '../utils/setTitle.js'
// Vue.use(VueRouter); // Vue.use(插件)
if (!window.VueRouter) {
    // 没有使用传统的方式引入VueRouter
    Vue.use(VueRouter);
}

const router = new VueRouter({
    mode: 'history',
    // 路由配置
    routes,
})

router.afterEach((to, from) => {
    if (to.meta.title) {
        setTitle.setRouterTitle(to.meta.title)
    }
})

export default router;

